package performanceTests.modules;
import java.util.Date;
import javax.swing.SwingUtilities;
import report.Report;
import vg.configuration.SimpleConfiguration;
import vg.core.VisualGraph;
import vg.core.plugin.PluginParameter;
import vg.logging.FileLog;
import vg.logging.SimpleLog;
import vg.logging.WindowMessage;
import vg.model.SQLite4JavaModel;
import vg.modules.backlight.PathSelectingPlugin;
import vg.modules.desktop.DesktopPlugin;
import vg.modules.filter.FilterPlugin;
import vg.modules.notepad.NotepadPlugin;
import vg.modules.opener.GUIOpener;
import vg.modules.projectStorable.StorablePlugin;
import vg.modules.search.SearchPlugin;
import vg.progress.SimpleProgressManager;
import vg.userInterface.SwingUserInterface;
import vg.userInterface.attributePanel.AttributePlugin;
import vg.userInterface.jgraphx.JGraphSettings;
import vg.userInterface.jgraphx.mxLayoutsRegister;
import vg.userInterface.scaling.ZoomPlugin;
import vg.userInterface.tabCloser.SimpleTabCloser;
import vg.userInterface.utilPlugins.GraphLayoutManager;
import vg.userInterface.utilPlugins.LookAndFeelChanger;
import vg.userInterface.utilPlugins.UndoAndRedo;
import junit.framework.Assert;
import junit.framework.TestCase;
public class CreatingModule extends TestCase {
public CreatingModule(String s) {
super(s);
// set all system services------------
try {
VisualGraph.setLog(new FileLog());
} catch (Throwable ex) {
ex.printStackTrace();
VisualGraph.setLog(new SimpleLog());
}
VisualGraph.setWindowMessage(new WindowMessage());
VisualGraph.setConfiguration(SimpleConfiguration.getInstance());
VisualGraph.setProgressManager(new SimpleProgressManager());
}
public void creatingAllModules() {
try {
System.out.println("\n[CreatingModule.creatingAllModules]");
int i;
System.out.println("Warmup state:");
for(i = 0; i < 3; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
new SimpleTabCloser(view);
new DesktopPlugin().install(param);
new mxLayoutsRegister(view.getGraphLayoutManager());
new FilterPlugin().install(param);
new UndoAndRedo().install(param);
new SearchPlugin().install(param);
new GUIOpener().install(param);
new JGraphSettings().install(param);
new LookAndFeelChanger().install(param);
new NotepadPlugin().install(param);
new PathSelectingPlugin().install(param);
new AttributePlugin().install(param);
new StorablePlugin().install(param);
new ZoomPlugin().install(param);
view.quit();
}
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(i = 0; i < 5; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
long start = new Date().getTime();
new SimpleTabCloser(view);
new DesktopPlugin().install(param);
new mxLayoutsRegister(view.getGraphLayoutManager());
new FilterPlugin().install(param);
new UndoAndRedo().install(param);
new SearchPlugin().install(param);
new GUIOpener().install(param);
new JGraphSettings().install(param);
new LookAndFeelChanger().install(param);
new NotepadPlugin().install(param);
new PathSelectingPlugin().install(param);
new AttributePlugin().install(param);
new StorablePlugin().install(param);
new ZoomPlugin().install(param);
view.quit();
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
Report.addRecord("CreatingModule", "creatingAllModules", Float.valueOf(best).toString(), "sec");
Assert.assertTrue(true);
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("CreatingModule", "creatingAllModules", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
}
}
public void creatingSimpleTabCloser() {
try {
System.out.println("\n[CreatingModule.creatingSimpleTabCloser]");
int i;
System.out.println("Warmup state:");
for(i = 0; i < 3; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
// adding system functions--------
new SimpleTabCloser(view);
view.quit();
}
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(i = 0; i < 5; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
// adding system functions--------
long start = new Date().getTime();
new SimpleTabCloser(view);
view.quit();
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
Report.addRecord("CreatingModule", "creatingSimpleTabCloser", Float.valueOf(best).toString(), "sec");
Assert.assertTrue(true);
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("CreatingModule", "creatingSimpleTabCloser", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
}
}
public void creatingLookAndFeelChanger() {
try {
System.out.println("\n[CreatingModule.creatingLookAndFeelChanger]");
int i;
System.out.println("Warmup state:");
for(i = 0; i < 3; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
new LookAndFeelChanger().install(param);
view.quit();
}
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(i = 0; i < 5; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
long start = new Date().getTime();
new LookAndFeelChanger().install(param);
view.quit();
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
Report.addRecord("CreatingModule", "creatingLookAndFeelChanger", Float.valueOf(best).toString(), "sec");
Assert.assertTrue(true);
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("CreatingModule", "creatingLookAndFeelChanger", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
}
}
public void creatingGraphSettings() {
try {
System.out.println("\n[CreatingModule.creatingGraphSettings]");
int i;
System.out.println("Warmup state:");
for(i = 0; i < 3; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
new JGraphSettings().install(param);
view.quit();
}
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(i = 0; i < 5; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
long start = new Date().getTime();
new JGraphSettings().install(param);
view.quit();
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
Report.addRecord("CreatingModule", "creatingGraphSettings", Float.valueOf(best).toString(), "sec");
Assert.assertTrue(true);
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("CreatingModule", "creatingGraphSettings", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
}
}
public void StyleMetalApplying() {
String oldSkin = VisualGraph.config.getProperty(LookAndFeelChanger.CONF_STYLE);
try {
System.out.println("\n[CreatingModule.StyleMetalApplying]");
VisualGraph.config.setProperty(LookAndFeelChanger.CONF_STYLE, "metal");
int i;
System.out.println("Warmup state:");
for(i = 0; i < 3; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
new LookAndFeelChanger().install(param);
view.quit();
}
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(i = 0; i < 5; i++) {
SQLite4JavaModel model = new SQLite4JavaModel();
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
// adding system functions--------
long start = new Date().getTime();
new LookAndFeelChanger().install(param);
view.quit();
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
Report.addRecord("CreatingModule", "StyleMetalApplying", Float.valueOf(best).toString(), "sec");
Assert.assertTrue(true);
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("CreatingModule", "StyleMetalApplying", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
} finally {
VisualGraph.config.setProperty(LookAndFeelChanger.CONF_STYLE, oldSkin);
}
}
public void StyleSubstanceApplying() {
String oldSkin = VisualGraph.config.getProperty(LookAndFeelChanger.CONF_STYLE);
try {
System.out.println("\n[CreatingModule.StyleSubstanceApplying]");
VisualGraph.config.setProperty(LookAndFeelChanger.CONF_STYLE, "Business Black Steel");
int i;
System.out.println("Warmup state:");
for(i = 0; i < 3; i++) {
final SQLite4JavaModel model = new SQLite4JavaModel();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
try {
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
new LookAndFeelChanger().install(param);
view.quit();
} catch (Exception e) {
}
}
});
}
System.out.println("Stady state: It may take several minutes");
float best = -1;
for(i = 0; i < 5; i++) {
final SQLite4JavaModel model = new SQLite4JavaModel();
long start = new Date().getTime();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
try {
GraphLayoutManager layoutManager = new GraphLayoutManager();
SwingUserInterface view = new SwingUserInterface(model, "Welcome to Visual Graph", layoutManager);
PluginParameter param = new PluginParameter(model, view);
new LookAndFeelChanger().install(param);
view.quit();
} catch (Exception e) {
}
}
});
long finish = new Date().getTime();
if((best > 0 && (finish - start)/1000.0 < best) || best < 0) {
best = (finish - start)/1000.0f;
}
}
Report.addRecord("CreatingModule", "StyleSubstanceApplying", Float.valueOf(best).toString(), "sec");
Assert.assertTrue(true);
} catch (Throwable ex) {
ex.printStackTrace();
Report.addRecord("CreatingModule", "StyleSubstanceApplying", "Exception: " + ex.getMessage(), "");
Assert.assertTrue(ex.getMessage(), false);
} finally {
VisualGraph.config.setProperty(LookAndFeelChanger.CONF_STYLE, oldSkin);
}
}
}